/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TabTablePanel.java
 *
 * Created on Apr 15, 2011, 4:43:14 PM
 */

package com.fa.supporters;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.GNOME.Accessibility.Table;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;

/**
 *
 * @author tatung
 */
public class TabTablePanel extends javax.swing.JPanel {

    /** Creates new form TabTablePanel */

    private int id; // partner id
    private String title; // current tab's title
    private JMenuItem pupMenuItemEdit;
    private JMenuItem pupMenuItemDelete;
    private JMenuItem pupMenuItemAdd;
    private JPopupMenu pupMenu = new JPopupMenu();
    private Vector<String> productList;
    
    /** Creates new form TabTablePanel */
    public TabTablePanel(int id, String title) {
        initComponents();
        this.id = id;
        this.title = title;
        productList = new Vector<String>();
        productList = DbConnector.getProductList(false);
        productList.insertElementAt("Tất cả", 0);
        this.cbxProduct.setModel(new DefaultComboBoxModel(productList));
        this.jDateChooserFrom.setDateFormatString("yyyy-MM-dd");
        this.jDateChooserTo.setDateFormatString("yyyy-MM-dd");
        this.jTableContent.setShowVerticalLines(false);
        this.jTableContent.setShowHorizontalLines(false);
        //this.jTableContent.setBorder(BorderFactory.createEmptyBorder());

        //this.jTableContent.setModel(DbConnector.getBuyTransactionsTableModel(id));
        updateTable(cbxProduct.getSelectedItem().toString(), "", "");

        TransactionCellColorRenderer cr = new TransactionCellColorRenderer("Ngày");
        for(int i=0;i<this.jTableContent.getColumnCount();i++){
            //JOptionPane.showMessageDialog(null, "In for loop");
            this.jTableContent.getColumn(this.jTableContent.getColumnName(i)).setCellRenderer(cr);
        }

        jScrollPane1.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent ae) {
                //throw new UnsupportedOperationException("Not supported yet.");
                //System.out.println("Horizontal: " + ae.getValue());
                //updateTable();
            }
        });

        jScrollPane1.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent ae) {
                //throw new UnsupportedOperationException("Not supported yet.");
                //System.out.println("Vertical: " + ae.getValue());
                //updateTable();
            }
        });

        this.jTableContent.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);


        //popup tab table menu
        pupMenuItemEdit = new JMenuItem("Sửa dòng này");
        pupMenuItemEdit.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                //JOptionPane.showMessageDialog(null, "Edit");
                //edit
                int[] selectedRows = TabTablePanel.this.jTableContent.getSelectedRows();
                DefaultTableModel model = new DefaultTableModel();
                model.addColumn("MS");
                model.addColumn("Ngày");
                model.addColumn("Giờ");
                model.addColumn("Hàng");
                model.addColumn("S.lg");
                model.addColumn("Đ.V");
                model.addColumn("Giá");
                model.addColumn("Tiền");
                model.addColumn("Ghi chú");
                
                for(int i=0;i<selectedRows.length;i++){
                    Object tmp = TabTablePanel.this.jTableContent.getValueAt(selectedRows[i], 0);
                    if(tmp==null){
                        tmp = "";
                    }
                    //System.out.println("yeah");
                    if(tmp.equals("")){
                        selectedRows[i] = -1;
                    }
                    if(selectedRows[i] >=0){
                        //int idBuyTransaction = Integer.parseInt(jTableContent.getValueAt(selectedRows[i], 0).toString());
                        Vector tmpRow = new Vector();
                        for(int j=0;j<TabTablePanel.this.jTableContent.getColumnCount();j++){
                            tmpRow.add(TabTablePanel.this.jTableContent.getValueAt(selectedRows[i], j));
                        }
                        model.addRow(tmpRow);
                    }

                }

                pEditTable pet = new pEditTable(model);
                NotifyDescriptor nd = new NotifyDescriptor(pet,
                                                           "Sửa",
                                                           NotifyDescriptor.OK_CANCEL_OPTION,
                                                           NotifyDescriptor.PLAIN_MESSAGE,
                                                           null,
                                                           NotifyDescriptor.OK_OPTION);
                if(DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION){
                    JTable petTable = pet.getTableEdit();
                    Column
                    DefaultTableModel dtm = (DefaultTableModel)petTable.getModel();
                    for(int i=0;i<dtm.getColumnCount();i++){
                        int idBuyTransaction = Integer.parseInt(dtm.getValueAt(i, petTable.getColumnModel().getColumnIndex("idBuyTransaction")).toString());
                        String strDateTime = dtm.getValueAt(i, petTable.getC)
                        DbConnector.updateBuyTransaction(ABORT, title, title, title, TOP_ALIGNMENT, title, title);
                    }
                }

                //update table
//                updateTable(cbxProduct.getSelectedItem().toString(),
//                            (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(jDateChooserFrom.getDate()),
//                            (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(jDateChooserTo.getDate()));
                updateTable();
            }
        });
        this.pupMenu.add(pupMenuItemEdit);

        pupMenuItemDelete = new JMenuItem("Xóa dòng này");
        pupMenuItemDelete.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                if(JOptionPane.showConfirmDialog(TabTablePanel.this,
                                                 "Có chắc chắn là xóa dòng này không?",
                                                 "Xóa giao dịch",
                                                 JOptionPane.YES_NO_OPTION,
                                                 JOptionPane.WARNING_MESSAGE,
                                                 null) == JOptionPane.YES_OPTION){
                    //xoa dong
                    int[] selectedRows = TabTablePanel.this.jTableContent.getSelectedRows();

                    for(int i=0;i<selectedRows.length;i++){
                        if(TabTablePanel.this.jTableContent.getValueAt(selectedRows[i], 0).equals("")){
                            selectedRows[i] = -1;
                        }
                        if(selectedRows[i] >=0){
                            int idBuyTransaction = Integer.parseInt(jTableContent.getValueAt(selectedRows[i], 0).toString());
                            DbConnector.deleteBuyTransaction(idBuyTransaction);
                        }

                    }

                    JOptionPane.showMessageDialog(null, "Da xoa dong");
                    //update table
                    updateTable();
                }
            }
        });
        this.pupMenu.add(pupMenuItemDelete);

        pupMenu.addSeparator();

        pupMenuItemAdd = new JMenuItem("Thêm dòng mới");
        pupMenuItemAdd.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                pAddTransaction pat = new pAddTransaction(false, TabTablePanel.this.title);
                NotifyDescriptor nd = new NotifyDescriptor(pat,
                                                           "Thêm giao dịch",
                                                           NotifyDescriptor.OK_CANCEL_OPTION,
                                                           NotifyDescriptor.PLAIN_MESSAGE,
                                                           null,
                                                           NotifyDescriptor.OK_OPTION);
                if(DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION){
                    Object[][] data = pat.getData();
                    String date;
                    String PartnerName;
                    String ProductName;
                    float quantity;
                    String metric;
                    String note;
                    for(int i=0;i<data.length;i++){
                        for(int j=0;j<data[0].length - 1;j++){
                            if(data[i][j] == null){
                                JOptionPane.showMessageDialog(null, "Không đầy đủ thông tin, ko thêm gì hết!");
                                return;
                            }
                        }
                    }
                    for(int i=0;i<data.length;i++){
                        date = pat.getDateTime();
                        PartnerName = pat.getPartnerName();
                        ProductName = (String)data[i][0];
                        quantity = Float.parseFloat((String)data[i][1]);
                        metric = (String)data[i][2];
                        JOptionPane.showMessageDialog(null, metric);
                        note = (String)data[i][3];
                        DbConnector.addTransaction(false, date, PartnerName, ProductName, quantity, metric, note);
                    }
                }
                //update table
                updateTable();
            }
        });
        this.pupMenu.add(pupMenuItemAdd);
    }


    public void updateTable(String strProductNameFilter,
                            String strDateTimeFilterFrom,
                            String strDateTimeFilterTo){
        DefaultTableModel fullModel = DbConnector.getBuyTransactionsTableModel(TabTablePanel.this.id,
                                                                               strProductNameFilter,
                                                                               strDateTimeFilterFrom,
                                                                               strDateTimeFilterTo);
        addSummaryToModel(fullModel);

        TabTablePanel.
                this.
                jTableContent.
                setModel(fullModel);

        //sortAllRowsBy(fullModel, 1, true);
        fullModel.fireTableStructureChanged();

        formatCellAndColumn(fullModel);
    }

    public void updateTable(){
        String fromDateFilter = jDateChooserFrom.getDate()!=null?
                                (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(jDateChooserFrom.getDate()):
                                "";
        String toDateFilter = jDateChooserTo.getDate()!=null?
                              (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(jDateChooserTo.getDate()):
                              "";
        DefaultTableModel fullModel =
                DbConnector.getBuyTransactionsTableModel(TabTablePanel.this.id,
                                                         cbxProduct.getSelectedItem().toString(),
                                                         fromDateFilter,
                                                         toDateFilter);
        // add summary rows to model
        addSummaryToModel(fullModel);

        // apply model to table
        TabTablePanel.
                this.
                jTableContent.
                setModel(fullModel);

        // fire table change event
        fullModel.fireTableStructureChanged();

        // format cells and column in model (cell and column size)
        formatCellAndColumn(fullModel);

    }

    private void addSummaryToModel(DefaultTableModel fullModel){
        Object curDateVal = null;
        Object preDateVal = null;
        float moneyDateSum = 0;
        float quantityDateSum = 0;

        for(int i=0;i<fullModel.getRowCount();i++){
            curDateVal = fullModel.getValueAt(i, fullModel.findColumn("Ngày"));
            if(i>0){
                preDateVal = fullModel.getValueAt(i-1, fullModel.findColumn("Ngày"));
            }
            if(!curDateVal.equals("")){
                if(preDateVal!=null && !curDateVal.equals(preDateVal)){
                    // insert summary row here and reset moneyDateSum and quantityDateSum to 0
                    System.out.println("!#$%&quantitySum: " + quantityDateSum);
                    //Object[] insertedRowData = {"", "", "", "", quantityDateSum,  "", "", moneyDateSum,  ""};
                    Object[] summaryRowData = {null, null, null, "Tổng S.lg", quantityDateSum,  null, "Tổng tiền", moneyDateSum,  null};
                    fullModel.insertRow(i, summaryRowData);
                    moneyDateSum = 0;
                    quantityDateSum = 0;
                    i++;
                    Object[] blankRowData = {null, null, null, null, null,  null, null, null,  null};
                    fullModel.insertRow(i, blankRowData);
                    i++;
                }
                moneyDateSum += Float.parseFloat(fullModel.getValueAt(i, fullModel.findColumn("Tiền")).toString());
                quantityDateSum += Float.parseFloat(fullModel.getValueAt(i, fullModel.findColumn("S.lg")).toString());
            }
            if(fullModel.getRowCount()-1 == i){
                Object[] summaryRowData = {null, null, null, "Tổng S.lg", quantityDateSum,  null, "Tổng tiền", moneyDateSum,  null};
                fullModel.insertRow(i+1, summaryRowData);
                moneyDateSum = 0;
                quantityDateSum = 0;
                i++;
                Object[] blankRowData = {null, null, null, null, null,  null, null, null,  null};
                fullModel.insertRow(i+1, blankRowData);
                i++;
            }
        }
    }

    private void formatCellAndColumn(DefaultTableModel fullModel){
        TransactionCellColorRenderer cr = new TransactionCellColorRenderer("Ngày");
        for(int i=0;i<this.jTableContent.getColumnCount();i++){
            this.jTableContent.getColumn(this.jTableContent.getColumnName(i)).setCellRenderer(cr);
        }

        this.jTableContent.getColumn("Đ.V").setPreferredWidth(35);
        this.jTableContent.getColumn("Giờ").setPreferredWidth(45);
    }

    public void sortAllRowsBy(DefaultTableModel model, int colIndex, boolean ascending) {
        Vector data = model.getDataVector();
        Collections.sort(data, new ColumnSorter(colIndex, ascending));
        model.fireTableStructureChanged();
    }



    public int getID(){
        return id;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlSearchGroup = new javax.swing.JPanel();
        jDateChooserTo = new com.toedter.calendar.JDateChooser();
        jLabel1 = new javax.swing.JLabel();
        cbxProduct = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jDateChooserFrom = new com.toedter.calendar.JDateChooser();
        btnSearch = new javax.swing.JButton();
        btnProductListRefresh = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableContent = new javax.swing.JTable();

        pnlSearchGroup.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(TabTablePanel.class, "TabTablePanel.pnlSearchGroup.border.title"))); // NOI18N

        jLabel1.setText(org.openide.util.NbBundle.getMessage(TabTablePanel.class, "TabTablePanel.jLabel1.text")); // NOI18N

        cbxProduct.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbxProduct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxProductActionPerformed(evt);
            }
        });

        jLabel2.setText(org.openide.util.NbBundle.getMessage(TabTablePanel.class, "TabTablePanel.jLabel2.text")); // NOI18N

        jLabel3.setText(org.openide.util.NbBundle.getMessage(TabTablePanel.class, "TabTablePanel.jLabel3.text")); // NOI18N

        btnSearch.setText(org.openide.util.NbBundle.getMessage(TabTablePanel.class, "TabTablePanel.btnSearch.text")); // NOI18N

        btnProductListRefresh.setIcon(new javax.swing.ImageIcon("/media/Data/NetBeansWorkspace/FamilyAccounting/Supporters/src/com/fa/icons/RefreshIcon.png")); // NOI18N
        btnProductListRefresh.setText(org.openide.util.NbBundle.getMessage(TabTablePanel.class, "TabTablePanel.btnProductListRefresh.text")); // NOI18N
        btnProductListRefresh.setMaximumSize(new java.awt.Dimension(34, 28));
        btnProductListRefresh.setMinimumSize(new java.awt.Dimension(34, 28));
        btnProductListRefresh.setPreferredSize(new java.awt.Dimension(28, 28));
        btnProductListRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnProductListRefreshActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlSearchGroupLayout = new javax.swing.GroupLayout(pnlSearchGroup);
        pnlSearchGroup.setLayout(pnlSearchGroupLayout);
        pnlSearchGroupLayout.setHorizontalGroup(
            pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSearchGroupLayout.createSequentialGroup()
                .addGroup(pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlSearchGroupLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbxProduct, 0, 169, Short.MAX_VALUE))
                    .addGroup(pnlSearchGroupLayout.createSequentialGroup()
                        .addGap(59, 59, 59)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDateChooserFrom, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSearchGroupLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDateChooserTo, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSearch)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlSearchGroupLayout.createSequentialGroup()
                        .addComponent(btnProductListRefresh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(284, 284, 284))))
        );
        pnlSearchGroupLayout.setVerticalGroup(
            pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlSearchGroupLayout.createSequentialGroup()
                .addGroup(pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(cbxProduct, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(btnProductListRefresh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jDateChooserFrom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlSearchGroupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jDateChooserTo, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
                        .addComponent(jLabel1)
                        .addComponent(btnSearch, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel3)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTableContent.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableContent.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jTableContentMouseReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jTableContent);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlSearchGroup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pnlSearchGroup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cbxProductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxProductActionPerformed
        // TODO add your handling code here:
        updateTable();
        //String selectedItem = this.cbxProduct.getSelectedItem().toString();
        //JOptionPane.showMessageDialog(null, selectedItem);
        //((TabTablePanel)this.buyJTabbedPane.getSelectedComponent()).filterProductName(selectedItem);
    }//GEN-LAST:event_cbxProductActionPerformed

    private void btnProductListRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProductListRefreshActionPerformed
        // TODO add your handling code here:
        productList = DbConnector.getProductList(false);
        productList.insertElementAt("Tất cả", 0);
        this.cbxProduct.setModel(new DefaultComboBoxModel(productList));
}//GEN-LAST:event_btnProductListRefreshActionPerformed

    private void jTableContentMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableContentMouseReleased
        // TODO add your handling code here:
        if(evt.getButton() == MouseEvent.BUTTON3){
            int[] selectedRows = this.jTableContent.getSelectedRows();
            int clickRow = this.jTableContent.rowAtPoint(evt.getPoint());
            boolean flag = false;//flag to check if the clicked row is one of selecting rows
            for(int i=0;i<selectedRows.length;i++){
                if(selectedRows[i] == clickRow){
                    flag = true;
                    break;
                }
            }

            if(flag == false){ // clicked row is NOT one of selecting rows
                this.jTableContent.setRowSelectionInterval(this.jTableContent.rowAtPoint(evt.getPoint()),
                        this.jTableContent.rowAtPoint(evt.getPoint()));
            }



            pupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
        }
}//GEN-LAST:event_jTableContentMouseReleased


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnProductListRefresh;
    private javax.swing.JButton btnSearch;
    private javax.swing.JComboBox cbxProduct;
    private com.toedter.calendar.JDateChooser jDateChooserFrom;
    private com.toedter.calendar.JDateChooser jDateChooserTo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTableContent;
    private javax.swing.JPanel pnlSearchGroup;
    // End of variables declaration//GEN-END:variables

}
